{% extends 'base.html' %}
{% block head %}
	<link href="{{ path }}js/plugins/datatables/DT_bootstrap.css" rel="stylesheet">
	<link href="{{ path }}js/plugins/responsive-tables/responsive-tables.css" rel="stylesheet"> 
    
    <script src="{{ path }}js/demos/demo.tables.js"></script>
    <script src="{{ path }}js/plugins/datatables/jquery.dataTables.js"></script>
    <script src="{{ path }}js/plugins/datatables/DT_bootstrap.js"></script>
	<script src="{{ path }}js/plugins/responsive-tables/responsive-tables.js"></script>
    <script src="{{ path }}js/jquery.numeric.js"></script>
	<script src="{{ path }}js/demos/demo.ui-elements.js"></script>
	<script src="{{ path }}js/plugins/colorpicker/js/bootstrap-colorpicker.js"></script>
	<script src="{{ path }}js/plugins/timepicker/jquery.ui.timepicker.min.js"></script>
    
{% endblock %}

{% block javascript %}

function OnSubmitForm(){
	if(document.pressed == 'Exportar'){
		document.frm_filtro.action ="/inventario/informe_sismed/exportar/";
		document.frm_filtro.target = "_blank";
		return true;
	}

	if(document.pressed == 'Visualizar'){
		document.frm_filtro.action ="/inventario/informe_sismed/reporte/";
		document.frm_filtro.target = "_blank";
		return true;
	}
    
    else if(document.pressed == 'Reporte'){
		document.frm_filtro.action ="/inventario/informe_sismed/exportar/";
		document.frm_filtro.target = "_blank";
		return true;
	}
    
    else{
    	return false;
    }
}
{% endblock %}

{% block jquery %}
	function buscar() {
    	inicio = $('#fecha-inicio').attr('value');
        fin = $('#fecha-fin').attr('value');
        $.ajax({
            url: "/inventario/informe_sismed/buscar/",
            type: "POST",
            data : {'fecha-inicio':inicio, 
            		'fecha-fin':fin, 
                    csrfmiddlewaretoken : $('#csrf_token >div >input').attr("value")
                     },
            dataType: "html",
            success: function(datos) {
            	$('#resultados').html(datos);
            }
        });
	}
	        
	
	$("#btn_buscar").click(buscar);

    
{% endblock %}
{% load humanize %}
{% block contenido %}
	{{ request.session.control }}
    	<div class="span12">
			<div id="horizontal" class="widget widget-form">
				<div class="widget-header">	      				
					<h3>
						<i class="icon-pencil"></i>
						Reporte Producto / precio / proveedor
					</h3>
				</div> <!-- /widget-header -->
				
				<div class="widget-content">
						<table class="table table-striped table-bordered table-highlight" id="example" width="100%">
							<thead>
							<tr>
								<th width="10%" align="center">Codigo</th>
								<th width="25%" align="center">Medicamento</th>
								<th width="10%" align="center">Lote</th>
								<th width="25%" align="center">Proveedor</th>
								<th width="10%" align="center">No. Factura</th>
								<th width="5%" align="center">Cant.</th>
								<th width="10%" align="center">Precio</th>
							</tr>
							</thead>
							<tbody>
							{% for producto in Inventario %}
								<tr class="{% cycle '' 'odd' %}">
									<td align="left"><label>{{ producto.item.producto.codigo|default_if_none:"" }}</label></td>
									<td align="right"><label>{{ producto.item.producto.nombre }}</label></td>
									<td align="right"><label>{{ producto.item.lote }}</label></td>
									<td align="left"><label>{{ producto.item.factura_compra.proveedor.nombre }}</label></td>
									<td align="left"><label>{{ producto.item.factura_compra.numero }}</label></td>
									<td align="left"><label>{{ producto.cantidad }}</label></td>
									<td align="left"><label>{{ producto.item.valor_unitario|intcomma }}</label></td>
								</tr>
							{% endfor %}
							</tbody>
						</table>
				</div> <!-- /. widget-content -->
			</div>  <!-- horizontal -->
		</div> <!-- /.span12 -->
		
{% endblock %}